import API from '../../api/index'
import { generateGridList } from '../../utils'
const bannerList = [{
  image: 'https://6d6f-mock-weather-6g2jv4s1cede9cfc-1257609296.tcb.qcloud.la/banner/1715183320984.png?sign=f794e945383ef845e2d5910e72f3af9d&t=1715227132'
}, {
  image: 'https://6d6f-mock-weather-6g2jv4s1cede9cfc-1257609296.tcb.qcloud.la/banner/1715183282636.png?sign=67053e130968b3a6db0fdaf6b17b7f21&t=1715227336'
}, {
  image: 'https://6d6f-mock-weather-6g2jv4s1cede9cfc-1257609296.tcb.qcloud.la/banner/1715183218538.png?sign=b66cd43dba85ef71be01fe6ddc2425d6&t=1715227355'
}]


Page({
  data: {
    banner: [],
    gridList: generateGridList(100, 4)
  },
  onLoad() {
    this.getImgUrlList();
  },
  onReady() {
    wx.cloud.init({
      env: "mock-weather-6g2jv4s1cede9cfc",
    });
    wx.cloud
      .database()
      .collection("cloudbase-sample-banner")
      .where({
        status: "online",
      })
      .get({
        success: (res) => {
          this.setData({
            banner: res.data,
          });
        },
        fail: (res) => {
          this.setData({
            banner: bannerList,
          });
        }
      });
  },
  goWeatherPage() {
    wx.navigateTo({
      url: `/pages/weather/index`,
    });
  },
  getImgUrlList() {
    const fileID = `/mobile-photos/`;
    wx.cloud.callFunction({
      name: 'quickstartFunctions',
      data: {
        type: 'getImgsUrl',
        fileID
      },
      success: res => {
        console.log(res);
      },
      fail: err=> {

      }
    })
  }
});